package com.liyiyan.note.util;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

import android.content.Context;
import android.util.Log;
import android.widget.Toast;

public class HelperTool {
	public static boolean debug_flag = true;

	/**
	 * @param inStream
	 * @return
	 * @throws Exception
	 */
	public static byte[] readInputStream(InputStream inStream) throws Exception {
		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
		byte[] buffer = new byte[1024];
		int len = 0;
		while ((len = inStream.read(buffer)) != -1) {
			outStream.write(buffer, 0, len);
		}
		inStream.close();
		return outStream.toByteArray();
	}

	public static void showMessage(Context context, String msg) {
		Toast toast = Toast.makeText(context, msg, Toast.LENGTH_LONG);
		toast.show();
	}

	public static void debugMessage(String tag, String msg) {

	    if (debug_flag){ 
	        // the "then" clause: decrease current speed
	    	Log.i(tag, msg);
	    }
	}

}
